// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class LevelProgress extends cc.Component {

    @property(cc.Node)
    nodeProgress: cc.Node = null;

    @property(cc.Label)
    textCurLevel: cc.Label = null;

    @property(cc.Label)
    textNextLevel: cc.Label = null;

    private maxScore:number = 0;
    private curScore:number = 0;

    start () {

    }

    setLevelProgressInfo(curLevel:number,maxScore:number){
        this.nodeProgress.scale = 0;
        this.textCurLevel.string = curLevel.toString();
        this.textNextLevel.string = (curLevel + 1).toString();
        this.maxScore = maxScore;
        this.curScore = 0;
    }

    setProgress(score:number){
        this.curScore = score;
        this.nodeProgress.setScale(this.curScore/this.maxScore,1)
    }
}
